<#include "/custom.include">
<#include "/java_copyright.include">
<#assign className = table.className>   
<#assign classNameLower = className?uncap_first>
<#assign actionExtension = "do">
package ${basepackage}.action.web;

import java.util.Date;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import cn.fzfx.base.terminal.common.ErrorCode;
import cn.fzfx.base.web.common.BaseAction;
import ${basepackage}.domain.${className};
import ${basepackage}.service.${className}Service;

import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList;
import com.opensymphony.xwork2.ModelDriven;

<#include "/java_imports.include">
@Controller
@Scope("prototype")
public class ${className}Action extends BaseAction implements ModelDriven<${className}> {
	private ${className} ${classNameLower} = new ${className}();
    @Resource
    private ${className}Service ${classNameLower}Service;

    @Override
    public ${className} getModel() {
        return ${classNameLower};
    }

    /**
     * 分页查询列表
     */
    public void get${className}ListWithPage() {
        PageBounds pageBounds = new PageBounds(${classNameLower}.getPage(), ${classNameLower}.getRows());
        PageList<${className}> ${classNameLower}s = ${classNameLower}Service.getWithPage(${classNameLower}, pageBounds);
        fxResponse.setTotal(${classNameLower}s.getPaginator().getTotalCount());
        fxResponse.setRows(${classNameLower}s);
        fxResponse.setSuccess(true);
        fxResponse.doResponse();
    }

    /**
     * 添加列表
     */
    public void add() {
            ${classNameLower}Service.add(${classNameLower});
            fxResponse.doSuccessResponse("添加成功");
    }

    /**
     * 删除
     */
    public void delete() {
        if (${classNameLower}.getNid() == 0) {
            fxResponse.setErrCode(ErrorCode.PARAMS_ERROR.getCode());
            fxResponse.setSuccess(false);
        } else {
            ${classNameLower}Service.delete(${classNameLower}.getNid());
        }
        fxResponse.doSuccessResponse("删除成功");
    }

    /**
     * 修改
     */
    public void update() {
        if (${classNameLower}.getNid() == 0) {
            fxResponse.setErrCode(ErrorCode.PARAMS_ERROR.getCode());
            fxResponse.setSuccess(false);
        } else {
            ${classNameLower}Service.update(${classNameLower});
        }
        fxResponse.doSuccessResponse("修改成功");
    }

}